home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / CH6 / EMAGA6 / control / client / misc / chatbox.cs next >
Text File  |  2006-09-24  |  1KB  |  46 lines

  1. new MessageVector(MsgBoxMessageVector);
  2. $LastframeTarget = 0;
  3.  
  4.  
  5. function onChatMessage(%message, %voice, %pitch)
  6. {
  7.    if (GetWordCount(%message)) {
  8.       ChatBox.AddLine(%message);
  9.    }
  10. }
  11. function onServerMessage(%message)
  12. {
  13.    if (GetWordCount(%message)) {
  14.       ChatBox.AddLine(%message);
  15.    }
  16. }
  17.  
  18. function ChatBox::addLine(%this,%text)
  19. {
  20.    %textHeight = %this.profile.fontSize;
  21.    if (%textHeight <= 0)
  22.       %textHeight = 12;
  23.    %chatScrollHeight = getWord(%this.getGroup().getGroup().extent, 1);
  24.    %chatPosition = getWord(%this.extent, 1) - %chatScrollHeight +
  25.         getWord(%this.position, 1);
  26.    %linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
  27.    if (%linesToScroll > 0)
  28.       %origPosition = %this.position;
  29.    while( !chatPageDown.isVisible() && MsgBoxMessageVector.getNumLines() &&
  30.          (MsgBoxMessageVector.getNumLines() >= $pref::frameMessageLogSize))
  31.    {
  32.       %tag = MsgBoxMessageVector.getLineTag(0);
  33.       if(%tag != 0)
  34.          %tag.delete();
  35.       MsgBoxMessageVector.popFrontLine();
  36.    }
  37.    MsgBoxMessageVector.pushBackLine(%text, $LastframeTarget);
  38.    $LastframeTarget = 0;
  39.    if (%linesToScroll > 0)
  40.    {
  41.       chatPageDown.setVisible(true);
  42.       %this.position = %origPosition;
  43.    }
  44.    else
  45.       chatPageDown.setVisible(false);
  46. }